let arr=[1,2,3,,[4,5],[6,7,8,9]];
function returnSum(arry){
    let sum=0;
    arry.forEach(item=>{
        if(item instanceof Array){
            sum+=returnSum(item);

        }else{
            sum+=item
        }
    })
    return sum

    
      
}
console.log(returnSum(arr))//45
// reduce求和
let newArr=arr.flat(Infinity);
console.log(newArr);
let sum=newArr.reduce((prev,cur)=>{
    return prev+cur
},0)
console.log(sum)
    

